﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.General;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service
{
    public class IndustryPageContentService : IService<IndustryPageContent>
    {
        private readonly GenericRepository<IndustryPageContent> _industryPageContentRepository;
        private readonly IUnitOfWork _unitOfWork;

        public IndustryPageContentService(IUnitOfWork unitOfWork, GenericRepository<IndustryPageContent> industryPageContentRepository)
        {
            this._industryPageContentRepository = industryPageContentRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<IndustryPageContent> GetAllElements()
        {
            return _industryPageContentRepository.GetAll();
        }

        public IndustryPageContent GetElementById(int id)
        {
            return _industryPageContentRepository.GetById(id);
        }

        public void CreateElement(IndustryPageContent entity)
        {
            _industryPageContentRepository.Insert(entity);
        }

        public void UpdateElement(IndustryPageContent entity)
        {
            _industryPageContentRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _industryPageContentRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
